Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

122
Visualizações
"&" and ">>" number operator in C++?

I am trying to make a raycaster game in Javascript, and to do so, I am following this tutorial, which is written in C++.

My problem stems from trying to convert the following two lines to javascript:

int tx = (int)(texWidth * (floorX - cellX)) & (texWidth - 1);
color = (color >> 1) & 8355711; // make a bit darker

I don't know what the "&" and ">>" mean in those two lines. Is there an equivalent in Javascript?

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

>> is the right bit-shift operator and & is the bitwise-and operator, both of them are available in JavaScript

about 4 years ago · Juan Pablo Isaza Relatório

0

The code directly translates to JS with the removal of the (int) typecast and the replacement of int with let/var/const.

let tx = (texWidth * (floorX - cellX)) & (texWidth - 1);    
color = (color >> 1) & 8355711; // make a bit darker 

& is the bitwise and, >> is the bitshift right, explained well here.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda